import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.sql.*;

public class ProjectDetails extends HttpServlet
{
 public void service(HttpServletRequest req,HttpServletResponse resp) throws ServletException ,IOException
 {
  
try
{ 
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  Connection con =   DriverManager.getConnection("jdbc:odbc:psi","psi","psi");
  System.out.println("connection is created"+con);
 int  pcode=Integer.parseInt(req.getParameter("pcode").trim());
String statusdate=req.getParameter("statusdate");
String pname=req.getParameter("pname");
String pmanager=req.getParameter("pm");
String prosdate=req.getParameter("psd");
String proedate=req.getParameter("ped");
String actsdate=req.getParameter("asd");
String actedate=req.getParameter("aed");
System.out.println("gcode");
String tleader=req.getParameter("tl");
System.out.println("activity type");
int actualhours=Integer.parseInt(req.getParameter("ah").trim());
int phours=Integer.parseInt(req.getParameter("ph").trim());
System.out.println("actulahours:"+actualhours);
System.out.println("phours:"+phours);
String submit=req.getParameter("vittu");

System.out.println("submit value"+submit);
  Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
if(submit.equals("Save"))
  	{
     
 PreparedStatement pstmt=con.prepareStatement("insert into project values(?,?,?,?,?,?,?,?,?,?,?,?)");
 	pstmt.setInt(1,pcode);
	 pstmt.setString(2,pname);
	pstmt.setString(3,pmanager);                              	
 	pstmt.setString(4,tleader);
	pstmt.setString(5,statusdate);
	pstmt.setString(6,prosdate);
	pstmt.setString(7,proedate);
	pstmt.setString(8,actsdate);
	pstmt.setString(9,actedate);
	System.out.println("actedate:"+actedate);
                   pstmt.setString(10,"");
	pstmt.setInt(11,phours );
	System.out.println("phours:"+phours);
	pstmt.setInt(12,actualhours);
	System.out.println("actualhours:"+actualhours);
                  int kk=pstmt.executeUpdate(); 
                  if(kk>0)
                   System.out.println("succesfully inserted");  
}   

resp.sendRedirect("assign-details.htm");
}
catch(Exception e)
{
 e.printStackTrace();
 }
}
 }